package cn.com.http.httpmessage;

import cn.com.http.httpheader.HttpMethod;
import cn.com.http.httpheader.HttpTitle;
import cn.com.http.httpheader.HttpUrl;
import cn.com.http.httpheader.HttpVersion;
import cn.com.http.httpheader.HttpVersionList;

public class HttpRequest extends HttpMessage implements HttpVersionList {

	@Override
	protected HttpTitle newHttpTitle1() {
		return new HttpMethod();
	}

	@Override
	protected HttpTitle newHttpTitle2() {
		return new HttpUrl();
	}

	@Override
	protected HttpTitle newHttpTitle3() {
		return new HttpVersion();
	}

	public HttpRequest() {
		this(null, null, null);
	}

	public HttpMethod getMethod() {
		return (HttpMethod) getTitle1();
	}

	public HttpUrl getUrl() {
		return (HttpUrl) getTitle2();
	}

	public HttpVersion getVersion() {
		return (HttpVersion) getTitle3();
	}

	public HttpRequest(String method, String url, String version) {
		if (method != null)
			getMethod().set(method);
		if (url != null)
			getUrl().set(url);
		if (version != null)
			getVersion().set(version);
	}

	public HttpRequest(String method, String url) {
		this(method, url, VERSION_10);
	}
}
